%% Exercise 7
% For CIE4440

close all;clear all;clc;
%% 1.	What is the relation between measured conductivity and concentration of added salt.  
% Retreived from the diltution gauging tap
% y = 1E-07x^2 + 0.0005x - 0.0574
% where y is salinity [g/l] and x is conductivity [mS]
load data

%% 2.	Plot the concentration wave against time.
data.conc   = 1E-07*data.cond.^2 + 0.0005*data.cond - 0.0574;
data.relConc= data.conc-data.backConc;

figure(1)
plot(data.time,data.relConc)
xlabel('Time [s]');
ylabel('Concentration [g/l]');

%% 3.	What is the discharge?
area    = trapz(data.time,data.relConc);
M       = 500;  % [g] total dissolved at once, given.
Q       = M/area;

fprintf('The river discharge can be estimated at %f [m3/s]\n',Q);

%% 4.	How will this wave look like if 10 more minutes have passed and why this shape?
% From the plot made in 7.2, one can conclude that all the salt has past 
% This not only includes the advection of the flow, but also the dispersion
% (widening of the peak) and the retardation (peak leans to the left).

%% 5.	Why is it important to calibrate a conductivity meter?
% Error propagation into the following calculations. Solubility also
% depends on water temperature.
